package com.sgb.kjwl.view.ui.adapter.manage;

import android.content.Context;
import android.view.View;

import com.bumptech.glide.request.RequestOptions;
import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemIntellRightListBinding;
import com.sgb.kjwl.model.entity.manage.IPDetailEntity;
import com.sgb.kjwl.view.ui.activity.manage.IPDetailActivity;
import com.sgb.kjwl.view.ui.adapter.enterprise.TextViewBindingAdapter;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class DataForCompanyShopAdapter extends BaseRecycleAdapter<IPDetailEntity> {
    Context context;
    RequestOptions options;

    public DataForCompanyShopAdapter(Context context, List<IPDetailEntity> datas) {
        super(context, R.layout.item_intell_right_list, datas);
        this.context = context;

        options = new RequestOptions()
                .placeholder(R.drawable.null_img_list)//图片加载出来前，显示的图片
                .fallback( R.drawable.null_img_list) //url为空的时候,显示的图片
                .error(R.drawable.null_img_list);//图片加载失败后，显示的图片
    }

    @Override
    public void convert(ItemViewHolder holder, IPDetailEntity dataForShopCompanyTrendsEntity) {
        holder.setBinding(BR.trades, dataForShopCompanyTrendsEntity);

        ItemIntellRightListBinding itemTransListbinding = (ItemIntellRightListBinding) holder.getmBinding();
        itemTransListbinding.tvItemNameCompany.setText(TextViewBindingAdapter.setTextForColon(dataForShopCompanyTrendsEntity.getTypesOfPropertyRights()+"类型:"+dataForShopCompanyTrendsEntity.getType()));
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                IPDetailActivity.startAction(context,dataForShopCompanyTrendsEntity);
            }
        });
        itemTransListbinding.patentType.setText(dataForShopCompanyTrendsEntity.getType());
        itemTransListbinding.fieldCategory.setText(dataForShopCompanyTrendsEntity.getFieldClassName());
        if (dataForShopCompanyTrendsEntity.getState().isEmpty()) {
            itemTransListbinding.patentState.setText("");
        } else if (dataForShopCompanyTrendsEntity.getState().equals("2")) {
            itemTransListbinding.patentState.setText("授权已下证");
        } else if (dataForShopCompanyTrendsEntity.getState().equals("1")) {
            itemTransListbinding.patentState.setText("授权未下证");
        }
        switch (dataForShopCompanyTrendsEntity.getTypesOfPropertyRights()) {
            case "商标":
            case "版权":
                itemTransListbinding.llField.setVisibility(View.GONE);
                itemTransListbinding.llState.setVisibility(View.GONE);
                break;
            case "专利":
                itemTransListbinding.llField.setVisibility(View.VISIBLE);
                itemTransListbinding.llState.setVisibility(View.VISIBLE);
                break;
        }
    }


}
